package com.shun.auth.action;

import cn.hutool.core.util.CharsetUtil;
import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
import cn.hutool.crypto.symmetric.AES;
import com.shun.auth.config.ShunAuthProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;

@Slf4j
public class ShunAuthBaseAction {

    @Autowired
    protected StringRedisTemplate stringRedisTemplate ;

    @Autowired
    protected ShunAuthProperty authProperty;

    /**
     * 解析加密串
     * @param encryptStr
     * @return
     */
    public String decryptStr(String encryptStr){
        log.debug("加密串:{}",encryptStr);
        AES aes = new AES(Mode.CTS, Padding.PKCS5Padding, authProperty.getAesKey().getBytes(), authProperty.getAesIv().getBytes());
        return aes.decryptStr(encryptStr, CharsetUtil.CHARSET_UTF_8);
    }
}
